<!-- 发送邮件-->
<!-- 私有样式表  -->
<link rel="stylesheet" href="<?php echo $this->pagePath;?>/js/ckeditor/sample.css">
<link rel="stylesheet" href="<?php echo $this->pagePath;?>/js/swfupload/jucreate.css">
<style>
<!--
#inof_form{
	margin-top: 42px;
	border-top: 1px solid #B9B9B9;
}
input.ui-widget-content {
	height : 2em;
	line-height:2em;
	width:100%;
}
.mail_subject,.mail_from,.mail_to,.mail_attachment,.mail_body,.mail_buttons,.mail_moreconf{
	margin-top:12px;
}
.uploading {
	width: 887px !important;
	top: 0 !important;
	left: 25px;
	line-height: 17px !important;
}
-->
</style>

<form method="post" id="mail_form" action="<?php echo $this->pagePath?>/mail/add">
	<?php echo $this->form->id?>
	<?php echo $this->form->edite_status?>
	
	<!-- 发件人 -->
	<div class="mail_from">
		<div>发件人：</div>
		<div>
		<?php echo $this->form->from?>
		</div>
	</div>
	<!-- 收件人 -->
	<div class="mail_to">
		<div>收件人：</div>
		<div>
		<?php echo $this->form->to?>
		</div>
	</div>
	<!-- 主题 -->
	<div class="mail_subject">
		<div>主&nbsp;&nbsp;题：</div>
		<div>
		<?php echo $this->form->subject?>
		</div>
	</div>
	<!-- 附件 -->
	<div class="mail_attachment">	
		<input type="hidden" id="mail_attachment_name_input" name="attachment_name" />
		<input type="hidden" id="mail_attachment_mime_input" name="attachment_mime" />
		<span id="upload_button" title="最大附件容量为2M">添加附件</span>
		<input type="hidden" id="mail_attachment_input" name="attachment" />
		<div id="progressTarget" class="ui-widget-content"></div>
	</div>
	<!-- 邮件正文 -->
	<div class="mail_body">
		<div class="mail_editor" id="mail_editor">
			<textarea name="mail" id="mail" class=" ui-widget-content" rows="24" cols="80"></textarea>
		</div>
	</div>
	<!-- is approve_status -->
	<div class="mail_moreconf">
		<span id="approve_status_lable" >免审核:</span>
		<input type="checkbox" name="approve_status" value="1"/> 
	</div>
</form>
<!-- 按钮 -->
<div class="mail_buttons">
	<button data-st="1">发送</button>
	<button data-st="0">存草稿</button>
	<button data-st="-1">放弃</button>
</div>
	
<!-- js -->
<script type="text/javascript" src="<?php echo $this->pagePath;?>/js/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="<?php echo $this->pagePath;?>/js/swfupload/handlers.js"></script>
<script type="text/javascript" src="<?php echo $this->pagePath;?>/js/swfupload/swfupload.js"></script>
<script type="text/javascript">


$(function(){
	$(".mail_buttons button").button().click(function(event){
		var status = $(this).attr("data-st");
		switch(status){
		case 0:
			break;
		case 1:
			break;
		case -1:
			this.history.go(-1);
			return;
			break;
		default:
			break;
		}
		$("#edite_status").val(status);
		$("#mail_form")[0].submit();
	});
	//CKEDITOR.appendTo( 'mail_editor',
	//	null,
	//	'<p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p>'
	//);
	CKEDITOR.replace('mail',{
	    //filebrowserBrowseUrl: '/browser/browse.php',
	    //filebrowserImageBrowseUrl: '/browser/browse.php?type=Images',
	    //filebrowserUploadUrl: '/uploader/upload.php',
	    filebrowserImageUploadUrl: '<?php echo $this->pagePath;?>/file/ckeditupload'
	});

	var upTagId = zendform.uploadTag($("#mail_attachment_input"));//设置swfupload附着的element
	zendform.appendSWFupload({
		"file_size_limit":"2 MB"
		,"button_placeholder_id":upTagId //设置swfupload按钮附着的element，它来自上一条语句
		,"swfUploadLoaded":function(){
			$("#upload_button").next("div").css({height:0,position: "relative",left:50,top:-17});
		}
		,"button_image_url":"<?php echo $this->pagePath;?>/images/attachment.png"
		,"upload_start_handler":function(){
			//开始上传
			this.customSettings.progressTarget = "progressTarget"; //zendform.uploadingTag($("#mail_attachment_input"));
		}
		,"upload_error_handler":function(file, errorCode, message){
			//上传出错时
			alert("上传错误："+message);
			$("#progressTarget").html("上传错误："+message);
		}
		,"upload_success_handler" : function(file, serverData){
			$("#divFileProgress").attr("title"," 再次上传可替换该文件。");
			$("#mail_attachment_name_input").val(file.name);
			try{
				var response = $.parseJSON(serverData);
				$("#mail_attachment_mime_input").val(response.MIME);
			}catch(e){
			}
			zendform.uploadSuccess(file, serverData);
		}
	},{
		"ju_element":"mail_attachment_input" //通知上传的额外参数，这里的ju_element必须以ju开头，是返回值的复制element
	});
	$("#upload_button").next("div").css({height:0,position: "relative",left:50,top:-17});
	
});


</script>